import {defineStore} from "pinia"

interface MenuListItem {
    expanded: boolean
    id: string
    leaf: boolean
    target: string
    text: string
    children: MenuListItem[]
}

interface Wh {
    logogram: string;
    org_id: string;
    wh_code: string;
    wh_id: string;
    wh_name: string;
}

export default defineStore("menu", {
    state() {
        const menuList: MenuListItem[] = []
        const whList: Wh[] = []
        const menuVersion: string = ""

        return {
            menuVersion,
            whList,
            menuList
        }
    },
    getters: {},
    actions: {
        loadFromIndexDb(state) {
            this.$patch(state)
        },
        logout() {
            this.$patch({
                menuVersion: undefined,
                whList: undefined,
                menuList: undefined
            })
        }
    }
})
